<template>
	<view class="ex-mall-tab-page" :class="[$themeClass('page-bg-color')]">
		<!-- 头部 -->
		<view class="ex-mall-header" :class="[$themeClass('header-bg-color')]">
			<!-- #ifdef MP-WEIXIN -->
			<view class="ex-mall-header-mp-weixin-fill" :class="[$themeClass('header-title-color')]">搜索</view>
			<!-- #endif -->
			<view class="ex-mall-header-content">
				<view class="ex-mall-header-search">
					<input class="ex-mall-header-search-input" :class="[$themeClass('search-input-bg-color'), $themeClass('search-input-color')]" type="text"
					 placeholder="搜索商品..." :placeholder-class="$themeClass('search-input-placeholder')" />
					<view class="ex-mall-header-search-btn" @click="search" :class="[$themeClass('search-btn-bg-color'), $themeClass('search-btn-color')]">
						<view class="ex-mall-header-search-btn-icon ri-search-line"></view>
					</view>
				</view>
			</view>
		</view>

		<view class="ex-mall-panel classify" :class="[$themeClass('panel-another-bg-color')]">
			<view class="ex-mall-panel-title" :class="[$themeClass('panel-another-title-bg-color'), $themeClass('panel-another-title-color')]">
				<view class="text">分类</view>
			</view>
			<view class="ex-mall-panel-content" :class="[$themeClass('panel-another-content-bg-color')]">
				<view class="list">
					<view class="item" :class="{'item-thumbnail': x.thumbnail}" v-for="(x, xi) in classifies" :key="xi">
						<view class="thumbnail" v-if="x.thumbnail">
							<image class="img"></image>
						</view>
						<text class="text">{{x.name}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				classifies: [{
					thumbnail: 'a',
					name: '数码'
				}, {
					thumbnail: 'b',
					name: '配饰'
				}, {
					thumbnail: 'c',
					name: '鞋类'
				}, {
					thumbnail: 'd',
					name: '家具'
				}, {
					name: '生活'
				}, {
					name: '服饰'
				}, {
					name: '家居'
				}, {
					name: '背包'
				}, {
					name: '生活'
				}, {
					name: '服饰'
				}, {
					name: '家居'
				}, {
					name: '背包'
				}, {
					name: '生活'
				}, {
					name: '服饰'
				}, {
					name: '家居'
				}, {
					name: '背包'
				}, {
					name: '生活'
				}, {
					name: '服饰'
				}, {
					name: '家居'
				}, {
					name: '背包'
				}]
			}
		},
		mounted() {
			this.load()
			this.$emit('loaded', {
				name: 'search'
			})
		},
		methods: {
			load() {
				console.log('search on load')
			},
			show() {
				console.log('search on show')
			},
			hide() {
				console.log('search on hide')
			},
			search() {
				
			}
		}
	}
</script>

<style lang="scss">
	.ex-mall-panel.classify {
		.ex-mall-panel-content {
			padding-bottom: 24px;

			&>.list {
				display: flex;
				flex-wrap: wrap;
				justify-content: space-between;
				padding: 0 28px;

				&>.item {
					display: flex;
					justify-content: center;
					align-items: center;
					width: 41vw;
					height: 58px;
					margin-top: 10px;
					background-color: #FFFFFF;
					border: 2px solid #9093A2;
					border-radius: 12px;
					overflow: hidden;
					box-sizing: border-box;

					&:nth-child(1),
					&:nth-child(2) {
						margin-top: 0;
					}

					&>.text {
						font-size: 15px;
						font-weight: 600;
					}
				}

				&>.item-thumbnail {
					position: relative;
					height: 41vw;
					border: none;

					&>.thumbnail {
						width: 100%;
						height: 100%;

						&:before {
							content: "";
							position: absolute;
							top: 0;
							right: 0;
							bottom: 0;
							left: 0;
							z-index: 10;
							display: block;
							background-color: rgba(0, 0, 0, 0.1);
						}

						&>.img {
							width: 100%;
							height: 100%;
						}
					}

					&>.text {
						position: absolute;
						color: #FFFFFF;
					}

					&:nth-child(4n-3) {
						&>.thumbnail {
							&>.img {
								background-color: #98847D;
							}
						}
					}

					&:nth-child(4n-2) {
						&>.thumbnail {
							&>.img {
								background-color: #A06441;
							}
						}
					}

					&:nth-child(4n-1) {
						&>.thumbnail {
							&>.img {
								background-color: #645E66;
							}
						}
					}

					&:nth-child(4n) {
						&>.thumbnail {
							&>.img {
								background-color: #AA8B43;
							}
						}
					}
				}
			}
		}
	}
</style>
